package com.hyjx.framework.component.message;

//import org.apache.activemq.ActiveMQConnectionFactory;

/**
 * 消息队列类
 */
public class MessageQueue {
    public static void main(String[] args) {
    }

    /**
     * 发送消息
     *
     * @param toUserID   发送者id
     * @param fromUserID 接收人id
     * @param text       消息内容
     * @param title      消息标题
     * @param buskey     业务主键
     */
    public static void sendMessage(String toUserID, String fromUserID, String text, String title, String buskey) {
//		MessageServiceImpl messageServiceImpl = (MessageServiceImpl) SpringBeanUtil.getBean("messageServiceImpl");
//		MessageModel messageModel = new MessageModel();
//		messageModel.setMsgid(StringHelper.getPrimaryKey());
//		messageModel.setTouser(toUserID);
//		messageModel.setTousername(toUserID);
//		messageModel.setContent(text);
//		messageModel.setFromuser(fromUserID);
//		messageModel.setTitle(title==null ? "消息提醒" : title);
//		messageModel.setBus_pkey(buskey);
//		messageModel.setSendtime(StringHelper.getDateTime());
//		messageModel.setType("1");
//		messageServiceImpl.add(messageModel);
//        ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("tcp://172.22.0.150:61618");
//        try {
//			Connection connection = connectionFactory.createConnection();
//			connection.start();
//			Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
//			// Create the destination (Topic or Queue)
//			Destination destination = session.createQueue(toUserID);
//			MessageProducer producer = session.createProducer(destination);
//			producer.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
//			TextMessage message = session.createTextMessage(text);
//			message.setStringProperty("from", fromUserID);
//			producer.send(message);
//			session.close();
//			connection.close();
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
    }
}
